package com.gtw.modules.api.controller;

import java.util.List;
import java.util.Map;

import com.gtw.common.annotation.AuthIgnoreApi;
import com.gtw.common.utils.PageUtils;
import com.gtw.common.utils.Query;
import com.gtw.common.utils.R;
import com.gtw.modules.api.service.TbBannerService;
import com.gtw.modules.entity.TbBanner;
import com.gtw.modules.entity.TbCategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Banner
 *
 * @author wuye
 * @email www.baidu.com
 * @date 2018-02-06 15:19:47
 */
@RestController
@RequestMapping("/api/banner")
public class TbBannerController {
    @Autowired
    private TbBannerService bannerService;

    /**
     * 列表
     */
    @AuthIgnoreApi
    @RequestMapping("/list")
    public R list() {
        List<TbBanner> page = bannerService.findALL();
        return R.ok().put("data", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id) {
        TbBanner banner = bannerService.queryObject(id);

        return R.ok().put("banner", banner);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody TbBanner banner) {
        bannerService.save(banner);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody TbBanner banner) {
        bannerService.update(banner);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids) {
        bannerService.deleteBatch(ids);

        return R.ok();
    }

}
